package dao

import (
	"context"
	"log"

	"github.com/redis/go-redis/v9"
)

var (
	ctx         = context.Background()
	RedisClient *redis.Client
)

func InitRedis() {
	RedisClient = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "",
		DB:       0,  // 0 default-DB
		PoolSize: 10, // conn-pool size
	})
	if err := RedisClient.Ping(ctx).Err(); err != nil {
		panic("Redis connect fail: " + err.Error())
	}
	log.Println("Redis connection successful!")
}
